package com.kgc.config;

import com.kgc.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author hyj
 * @time 2024/4/2 9:18
 * @describe
 */

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Bean
    LoginInterceptor loginInterceptor() {
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截全部
        registry.addInterceptor(loginInterceptor()).addPathPatterns("/apis/*/*/**")
                //不拦截路径
                .excludePathPatterns("/apis/user/login", "/apis/user/register");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
